<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class profile extends CI_Controller {

	public function __construct()
    {
        parent::__construct();
        $all_session = $this->session->all_userdata();
    
        if($all_session['login'][0]['mem_id'] == '' )
        {
        	redirect('authen');
        } else if ($this->uri->segment(2) == '') { 
        	redirect('profile/index/'.$all_session['login'][0]['mem_id']);
        } else if ($this->uri->segment(2) == 'index' && $this->uri->segment(3) != $all_session['login'][0]['mem_id']) {
        	redirect('profile/index/'.$all_session['login'][0]['mem_id']);
        } else if ($this->uri->segment(3) != $all_session['login'][0]['mem_id']) {
        	redirect('profile/update/'.$all_session['login'][0]['mem_id']);
        }

    }

    public function index()
	{		
		$uri = $this->uri->segment(3);
		$data['member'] = $this->pmember_model->profile($uri);
		$this->load->view('profile',$data);
	}

	public function update()
	{
		////////////////////////////////////////////
		//////////////// input field ///////////////
		////////////////////////////////////////////

		$uri = $this->uri->segment(3);
		$data['member'] = $this->pmember_model->profile($uri);

		$this->load->view('update' ,$data);
	}


}